package com.example.blogslogin_and_register.service.Impl;


import com.example.blogslogin_and_register.domain.UserInfo;
import com.example.blogslogin_and_register.mapper.UserInfoMapper;
import com.example.blogslogin_and_register.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 登录注册业务实现
 * @author 啦啦啦
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo loginByMobile(UserInfo userInfo) {
        UserInfo user = userInfoMapper.selectByMobile(userInfo);
        if (user==null){
            return null;
        }else {
            return user;
        }
    }

    @Override
    public UserInfo register(UserInfo userInfo) {
        int row = userInfoMapper.insertSelective(userInfo);
        if (row!=0){
            return userInfoMapper.selectByPrimaryKey(userInfo.getUserid());
        }else {
            return null;
        }
    }
}
